<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__CSS__/bootstrap.min.css" >
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css">
    <style>
        .title_box{
            width: 100%;
            height: 35px;
            font-size: 24px;
            color: #3c8dbc;
            text-indent: 10px;
            line-height: 35px;
            font-weight: bold;
            border-bottom: 1px solid #ccc;
            margin: 20px auto;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="title_box">微信推送</div>
    <div class="wrapper">
        <div class="panel-body">
            <form class="layui-form" action="{:url('pushweixin')}" method="post">
                <div class=" form-group ">
                    <label for="cname" class="control-label col-lg-2">订单ID:</label>
                    <div class="col-lg-6">
                        <input class="form-control" type="text" value="{$info.id}" disabled>
                        <input class="form-control" type="hidden" name="id" value="{$info.id}">
                    </div>
                </div>
                <div class="form-group ">
                    <label for="cname" class="control-label col-lg-2">顾客姓名:</label>
                    <div class="col-lg-6">
                        <input class="form-control"  value="{$info.name}" type="text"  disabled="disabled" />
                    </div>
                </div>
                <div class=" form-group ">
                    <label for="cname" class="control-label col-lg-2">业务状态:</label>
                    <div class="col-lg-6">
                        <select class="form-control" name="ywstate" lay-verify="required" lay-filter="ywstate">
                            <option value="">{$info.state_text}</option>
                            {eq name='user' value='2'}<!--预约成功   邀约-->
                                {volist name='state' id='data'}
                                <option value="{$data.id}" {neq name='data.id' value='5'}disabled{/neq}  >{$data.name}</option>
                                {/volist}
                            {/eq}
                            {eq name='user' value='3'}<!--意向客资   渠道、网络、会所-->
                                {volist name='state' id='data'}
                                <option value="{$data.id}" {neq name='data.id' value='7'}disabled{/neq}  >{$data.name}</option>
                                {/volist}
                            {/eq}
                            {eq name='user' value='1'}<!--意向客资 预约成功 管理员、总经理等 -->
                                {volist name='state' id='data'}
                                <option value="{$data.id}" {if condition="($data.id != 5) AND ($data.id != 7) "} disabled{/if} >{$data.name}</option>
                                {/volist}
                            {/eq}
                        </select>
                    </div>
                </div>
                <div class=" form-group " id="yycg" lay-filter="yycg">
                    <label for="cname" class="control-label col-lg-2">预约场馆:</label>
                    <div class="col-lg-6">
                        <select class="form-control" name="yycg" lay-verify="required" id="yycg1" >
                            <option value="">请选择预约场馆</option>
                            {volist name='yycg' id='data'}
                            <option value="{$data.id}" {eq name="info.yycg" value="$data.id"}selected="selected"{/eq} >{$data.title}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class=" form-group " id="yypstime"  lay-filter="yypstime">
                    <label for="cname" class="control-label col-lg-2">预约时间:</label>
                    <div class="col-lg-6">
                        <input type="text" class="form-control" name="yypstime" id="yypstime1" lay-verify="required" onclick="laydate({min: laydate.now(),istime: true, format: 'YYYY-MM-DD hh:mm'})" {neq name="info.yypstime" value="1970-01-01 8:00"}value="{$info.yypstime}"{/neq}  >
                    </div>
                </div>

                <div class="form-group ">
                    <label for="cname" class="control-label col-lg-2">备注:</label>
                    <div class="col-lg-6">
                        <textarea name="bz" rows="8" style="width: 100%;" placeholder="请填写备注" lay-verify="required">{neq name='bz' value='0'}{$bz}{/neq}</textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn"  lay-filter="*" lay-submit id="submit">推送</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <script type="text/javascript" src="__JS__/jquery-2.2.3.min.js"></script>
    <script type="text/javascript" src="__STATIC__/layui/layui.js"></script>
    <script type="text/javascript" src="__STATIC__/laydate/laydate.js"></script>

    <script>
        layui.use('form', function(){
            var $ = layui.jquery, form = layui.form();
            $('#yycg').hide();
            $('#yypstime').hide();
            $("#yycg1").removeAttr('lay-verify');
            $("#yypstime1").removeAttr('lay-verify');
            $("#yycg1").attr("disabled",true);
            $("#yypstime1").attr("disabled",true);
            form.on('select(ywstate)',function (data) {
                if(data.value == 5){
                    $('#yycg').show();
                    $('#yypstime').show();
                    $("#yycg1").attr("lay-verify","required");
                    $("#yypstime1").attr("lay-verify","required");
                    $("#yycg1").removeAttr('disabled');
                    $("#yypstime1").removeAttr('disabled');
                }else{
                    $('#yycg').hide();
                    $('#yypstime').hide();
                    $("#yycg1").removeAttr('lay-verify');
                    $("#yypstime1").removeAttr('lay-verify');
                    $("#yycg1").attr("disabled",true);
                    $("#yypstime1").attr("disabled",true);
                }
            });

            form.on('submit(*)', function (data) {
                $.ajax({
                    url: data.form.action,
                    type: data.form.method,
                    data: $(data.form).serialize(),
                    beforeSend:function(){
                        $('#submit').attr("disabled","false"); //禁止点击
                    },
                    success: function (msg) {
//                        console.log(msg);

                        $('#submit').attr("disabled","false"); //禁止点击
                        layer.msg(msg.msg, {icon: msg.icon});
                        if(msg.status ==1 ){
                            setTimeout(function(){
                                parent.layer.closeAll();
                            },3000);
                        }else{
                            setTimeout(function(){
                                location.href=msg.url;
                                $('#submit').removeAttr("disabled"); //禁止点击
                            },3000);
                        }
                    }
                });
                return false;
            });

        });
    </script>

</body>
</html>